// Copyright (C) 2013 eezstreet
// This file is part of the "Irrlicht Engine".
// IMemoryFile.h is a custom file included in BaseEngine, and the contents are to be released under an SVN.
// For conditions of distribution and use, see copyright notice in irrlicht.h

#ifndef __IMEMORYFILE_DEFINED
#define __IMEMORYFILE_DEFINED

#include "IReadFile.h"
#include "IWriteFile.h"

namespace irr
{
namespace io
{
	class IMemoryFile : public IReadFile, public IWriteFile
	{
		/*!
		  Class for reading and writing from memory.
		*/
	public:
		//! Destructor
		virtual ~IMemoryFile() {};

		//! returns how much was read
		virtual s32 read(void* buffer, u32 sizeToRead) = 0;

		//! returns how much was written
		virtual s32 write(const void* buffer, u32 sizeToWrite) = 0;

		//! changes position in file, returns true if successful
		virtual bool seek(long finalPos, bool relativeMovement = false) = 0;

		//! returns size of file
		virtual long getSize() const = 0;

		//! returns where in the file we are.
		virtual long getPos() const = 0;

		//! returns name of file
		virtual const io::path& getFileName() const = 0;
	protected:
		void *Buffer;
		long Len;
		long Pos;
		io::path Filename;
		bool deleteMemoryWhenDropped;
	};

	IMemoryFile* createMemoryFile(void *memory, const path& fileName, long size, bool deleteMemoryWhenDropped);
}
}

#endif  // __IMEMORYFILE_DEFINED